package com.allprs.common.utils;

import java.math.BigDecimal;
import java.util.StringTokenizer;

public class CpuInfoBean {
    // /proc/stat中cpu数据10元组
    private BigDecimal user, nice, system, idle, iowait, irq, softirq, stealstolen, guest, guest_nice;

    public CpuInfoBean(StringTokenizer procStatFirstLine) {
        procStatFirstLine.nextToken();
        this.user = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.nice = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.system = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.idle = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.iowait = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.irq = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.softirq = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.stealstolen = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.guest = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
        this.guest_nice = procStatFirstLine.hasMoreTokens() ? new BigDecimal(procStatFirstLine.nextToken()) : BigDecimal.ZERO;
    }

    public BigDecimal getCpuTotal() {
        return user.add(nice).add(system).add(idle).add(iowait).add(irq).add(softirq).add(stealstolen).add(guest).add(guest_nice);
    }

    public BigDecimal getUser() {
        return user;
    }

    public void setUser(BigDecimal user) {
        this.user = user;
    }

    public BigDecimal getNice() {
        return nice;
    }

    public void setNice(BigDecimal nice) {
        this.nice = nice;
    }

    public BigDecimal getSystem() {
        return system;
    }

    public void setSystem(BigDecimal system) {
        this.system = system;
    }

    public BigDecimal getIdle() {
        return idle;
    }

    public void setIdle(BigDecimal idle) {
        this.idle = idle;
    }

    public BigDecimal getIowait() {
        return iowait;
    }

    public void setIowait(BigDecimal iowait) {
        this.iowait = iowait;
    }

    public BigDecimal getIrq() {
        return irq;
    }

    public void setIrq(BigDecimal irq) {
        this.irq = irq;
    }

    public BigDecimal getSoftirq() {
        return softirq;
    }

    public void setSoftirq(BigDecimal softirq) {
        this.softirq = softirq;
    }

    public BigDecimal getStealstolen() {
        return stealstolen;
    }

    public void setStealstolen(BigDecimal stealstolen) {
        this.stealstolen = stealstolen;
    }

    public BigDecimal getGuest() {
        return guest;
    }

    public void setGuest(BigDecimal guest) {
        this.guest = guest;
    }

    public BigDecimal getGuest_nice() {
        return guest_nice;
    }

    public void setGuest_nice(BigDecimal guest_nice) {
        this.guest_nice = guest_nice;
    }
}
